package com.gmail.hongyz.myfuse.common;

import javax.servlet.http.HttpServletRequest;

public class PageObject {

	private int start;
	private int limit;
	private int total;
	
	private PageObject() {
		
	}
	
	public static PageObject createPageObject() {
		int start = 0;
		int limit = 25;
		int total = -1;
		PageObject pageObject = new PageObject();
		pageObject.start = start;
		pageObject.limit = limit;
		pageObject.total = total;
		return pageObject;
	}
	public static PageObject parseParams(HttpServletRequest request) {
		int start = 0;
		int limit = 25;
		int total = -1;
		try {
			start = Integer.parseInt(request.getParameter("start"));
			limit = Integer.parseInt(request.getParameter("limit"));
			total = Integer.parseInt(request.getParameter("total"));
		} catch (NumberFormatException e) {
		}
		PageObject pageObject = new PageObject();
		pageObject.start = start;
		pageObject.limit = limit;
		pageObject.total = total;
		return pageObject;
	}
	public int getStart() {
		return start;
	}
	public void setStart(int start) {
		this.start = start;
	}
	public int getLimit() {
		return limit;
	}
	public void setLimit(int limit) {
		this.limit = limit;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}
}
